<script setup lang="ts">

import {ref, watchEffect} from "vue";

const props = defineProps<{ type: boolean, fn: () => any }>()
const title = ref<string>('')
watchEffect(() => {
  if (props.type) {
    title.value = '删除'
  } else {
    title.value = '添加'
  }
})

</script>

<template>
  <div>
    <button @click="fn">{{ title }}</button>
  </div>
</template>

<style scoped>

button {
  padding: 5px 10px;
}
</style>